package org.mathig.poker.hand;

import java.util.List;

import org.mathig.poker.Card;
import org.mathig.poker.PokerRank;
import org.mathig.poker.Rank;

public class FullHouse extends AbstractHand {

	private List<Card> set;

	private List<Card> pair;

	public FullHouse(List<Card> threeCards, List<Card> twoCards) {
		this.set = threeCards;
		this.pair = twoCards;
	}

	public String cards() {
		return set + " " + pair;
	}

	@Override
	public String toString() {
		return getSetRank() + " full over " + getPairRank();
	}

	private Rank getSetRank() {
		return set.get(0).getRank();
	}

	private Rank getPairRank() {
		return pair.get(0).getRank();
	}

	public int compareTo(Hand hand) {
		int compare = super.compareTo(hand);
		if (compare != 0)
			return compare;
		if (hand instanceof FullHouse) {
			FullHouse twoPair = (FullHouse) hand;
			// compare pair1 rank
			compare = getSetRank().compareTo(twoPair.getSetRank());
			if (compare != 0)
				return compare;
			// compare pair2 rank
			compare = getPairRank().compareTo(twoPair.getPairRank());
			return compare;
		}
		return compare;
	}

	public PokerRank getPokerRank() {
		return PokerRank.FULL_HOUSE;
	}

}
